package com.bstek.uflo.samplecenter;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;

//@EnableTransactionManagement(proxyTargetClass = true)
//@org.springframework.context.annotation.PropertySource(value = {"application2.properties"})
@SpringBootApplication(exclude = {HibernateJpaAutoConfiguration.class})
//@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class UfloApplication {
	public static void main(String[] args) throws SQLException {
		ConfigurableApplicationContext context=SpringApplication.run(UfloApplication.class, args);
		Environment env=context.getEnvironment();
        Map<String, Object> map = new HashMap<String, Object>();
        for(Iterator<?> it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext(); ) {
        	PropertySource<?> propertySource = (PropertySource<?>) it.next();
        	System.out.println(propertySource.getClass());
        	if (propertySource instanceof MapPropertySource) {
        		map.putAll(((MapPropertySource) propertySource).getSource());
        	}
        }
       
        for(String k:map.keySet()) {
        	System.out.println(k+":"+map.get(k));
        }
	}
}
